﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CommonLibrary
{
    /// <summary>
    /// 随机数lib
    /// </summary>
    public class RandomHelper
    {
        ///<summary>   
        ///订单编号生成
        ///</summary>    
        ///<returns>返回订单号</returns>   
        public static string CreateOrderNumber()
        {
            //使用Guid.NewGuid().GetHashCode()作为种子，可以确保Random在极短时间产生的随机数尽可能做到不重复   
            Random rand = new Random(Guid.NewGuid().GetHashCode());
            //var number = "DD" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + rand.Next(10000, 99999).ToString();
            return string.Format("DD{0:yyyyMMddHHmmssfff}{1}", DateTime.Now, rand.Next(10000, 99999));//WxPayConfig.MCHID,
            //return number;
        }
        /// <summary>
        /// 充电宝编号
        /// </summary>
        /// <returns></returns>
        public static string CreateChargingNumber()
        {
            Random rand = new Random(Guid.NewGuid().GetHashCode());
            return string.Format("CDB{0:yyyyMMddHHmmss}{1}", DateTime.Now, rand.Next(1000, 9999));//WxPayConfig.MCHID,
        }
        /// <summary>
        /// 手机验证码
        /// </summary>
        /// <returns></returns>
        public static string CreateShouJiYanZhengMa()
        {
            Random rand = new Random(Guid.NewGuid().GetHashCode());
            return string.Format("{0}", rand.Next(100000, 999999));//WxPayConfig.MCHID,
        }
    }
}
